home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Programmer's Power Pack
/
Delphi Volume 1.iso
/
e_to_l
/
fbuilder
/
delphi
/
demos
/
fltdemfm.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-09-15
|
3KB
|
127 lines
unit Fltdemfm;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, DBTables, DB, Grids, DBGrids, StdCtrls,
ExtCtrls, Buttons ,FiltrFrm,fbcomp,fbdbcomp;
type
TForm1 = class(TForm)
CustomerTable: TTable;
CustomerDataSource: TDataSource;
CustomerGrid: TDBGrid;
FilterPanel: TPanel;
CustomerTableCustNo: TFloatField;
CustomerTableCompany: TStringField;
CustomerTableAddr1: TStringField;
CustomerTableCity: TStringField;
CustomerTableState: TStringField;
CustomerTableZip: TStringField;
CustomerTableCountry: TStringField;
CustomerTablePhone: TStringField;
CustomerTableFAX: TStringField;
CustomerTableTaxRate: TFloatField;
CustomerTableContact: TStringField;
CustomerTableLastInvoiceDate: TDateTimeField;
ResultsPanel: TPanel;
OrdersDatasource: TDataSource;
OrdersGrid: TDBGrid;
Formula: TBitBtn;
OrdersTable: TTable;
OrdersTableOrderNo: TFloatField;
OrdersTableItemsTotal: TCurrencyField;
OrdersTableFreight: TCurrencyField;
OrdersTableAmountPaid: TCurrencyField;
OrdersTablePaymentMethod: TStringField;
OrdersTableCustNo: TFloatField;
CustomerFilter: TDSFilter;
DBExpression: TDBExpression;
BitBtn3: TBitBtn;
GroupBox1: TGroupBox;
FilterBtn: TBitBtn;
cbxApplyFilter: TCheckBox;
FilterLabel: TLabel;
procedure FormCreate(Sender: TObject);
procedure FilterBtnClick(Sender: TObject);
procedure FormulaClick(Sender: TObject);
procedure CustomerDataSourceDataChange(Sender: TObject; Field: TField);
procedure OrdersDatasourceDataChange(Sender: TObject; Field: TField);
procedure cbxApplyFilterClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Procedure UpdateResults;
Procedure RefreshDisplay;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
uses DBExprFm;
procedure TForm1.FormCreate(Sender: TObject);
begin
CustomerTable.Active := True;
DBExpression.Database := CustomerTable.Database;
end;
procedure TForm1.FilterBtnClick(Sender: TObject);
begin
if BuildDSExpression('Filter Expression',[vtBoolean],
CustomerFilter,
CustomerFilter.DataSource.Dataset) then
begin
RefreshDisplay;
end;
end;
procedure TForm1.FormulaClick(Sender: TObject);
begin
DBExpression.Database := CustomerTable.Database;
if BuildDBExpression('Database Expression Example',DBExpression) then
UpdateResults;
end;
Procedure TForm1.UpdateResults;
begin
if DBExpression.isNull then
ResultsPanel.Caption := ''
else
ResultsPanel.Caption := ' > '+DBExpression.AsString;
end;
Procedure TForm1.RefreshDisplay;
begin
FilterPanel.Caption := ' > ' + CustomerFilter.Formula;
CustomerFilter.Refresh;
CustomerGrid.Invalidate;
CustomerTable.First;
end;
procedure TForm1.CustomerDataSourceDataChange(Sender: TObject;Field: TField);
begin
UpdateResults;
end;
procedure TForm1.OrdersDatasourceDataChange(Sender: TObject;Field: TField);
begin
UpdateResults;
end;
procedure TForm1.cbxApplyFilterClick(Sender: TObject);
begin
CustomerFilter.Active := cbxApplyFilter.Checked;
RefreshDisplay;
end;
end.